/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/service.hpp>
#include <baja/graphics/graphics_types.hpp>

namespace baja { namespace graphics {
// types
inline packed_color packColor(const uint32 r, const uint32 g, const uint32 b);
inline packed_color packColor(const uint32 a, const uint32 r, const uint32 g, const uint32 b);
inline packed_color packNormalizedColor(const float32 r, const float32 g, const float32 b);
inline packed_color packNormalizedColor(const float32 a, const float32 r, const float32 g, const float32 b);
inline uint8 unpackColj_A(const packed_color c);
inline uint8 unpackColor_R(const packed_color c);
inline uint8 unpackColor_G(const packed_color c);
inline uint8 unpackColor_B(const packed_color c);

struct display_params;
struct color;
struct light;
struct texture_coordinate;
struct vertex_lit_colored_textured;
struct vertex_screen_colored_textured;
struct viewport;
struct render_transforms;
struct effect2_description;
struct constant_buffer_description;

// interfaces
struct irender_object;
struct irender_service;
struct ifont;
struct iasset_manager;
struct imaterial;
struct imaterial_collection;
struct icollision_resolver;
struct imesh;
struct iscene_transformer;
struct idynamic_vertex_buffer;
struct ieffect2;
struct iindex_buffer;
struct isurface;
struct itexture;
struct ivertex_buffer;
struct ivertex_declaration;
struct iengine;

void checkIsValid(const bool useWARP);

std::shared_ptr<iengine> createEngine(
    const std::shared_ptr<iservice_map>& services,
    const bool useWARP,
    const display_params& dp,
    const void* context
    );

std::shared_ptr<imaterial> createMaterial();

std::shared_ptr<idynamic_vertex_buffer>
createDynamicVertexBuffer(
    const std::shared_ptr<iengine>& graphics,
    const std::shared_ptr<ivertex_declaration>& vertexDecl,
    const uint32 vertexSize,
    const uint32 totalVertices
    );

std::shared_ptr<imaterial_collection> createMaterialCollection(
    const std::vector<std::shared_ptr<imaterial>>& materials,
    const std::vector<std::string>& materialNames
    );

std::shared_ptr<iasset_manager> createAssetManager();

std::shared_ptr<iscene_transformer> createSceneTransformer();

std::shared_ptr<irender_service> createRenderService();

std::shared_ptr<ifont> createFont(
    const std::shared_ptr<iengine>& graphics,
    const wchar* fontName,
    const uint32 fontHeight,
    const bool rightToLeft
    );

std::shared_ptr<imesh> createMesh(
    const std::shared_ptr<iengine>& graphics,
    vertex_lit_colored_textured* vertices,
    const uint32 totalVerts,
    const uint16* indices,
    const uint32 totalIndices,
    const primitive_type primitiveType,
    const uint32 primitiveCount
    );

}} // namespace baja.graphics
